﻿using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public class Ch01Controller : Controller
    {
        InvoiceManagementDbContext db=new InvoiceManagementDbContext();
        public IActionResult Demo01()
        {
            var listView = from emp in db.Invoices
                           select new
                           {
                               Id = emp.Id,
                               Category = emp.Category,
                               Amount = emp.Amount,

                           };
            ViewBag.listView = listView;

            var totalAmount = db.Invoices.Sum(emp => emp.Amount);
            ViewBag.totalAmount = totalAmount;

            return View();
        }
    }
}
